// pages/ck_qs/ck_qs.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    yc_s1:"display:none"
  },
  ht_cz1:function(e){
    var that = this;
    that.setData({
      yc_s:"display:block"
    })
  },
  tiaozhuan:function(e){
    var wbl = e.currentTarget.dataset.id;
    wx.navigateTo({
     url: '../ganggao_x1/ganggao_x1?nei='+wbl,
   });
 },
  zhidao:function(e){
    var that = this;
    var he_id = e.currentTarget.dataset.id; 
    wx.request({
      url: app.globalData.url_l + 'api/member/hetong_de',
      method: 'post',
      data:{
          uid:app.globalData.uid,
          id:he_id
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        if(res.data.code==1){
              that.setData({
                  yc_s:"display:none"
                })
                wx.showToast({
                  title: '撤回成功！',
                  icon: 'success',
                  duration: 1000,
                  success:function(){
                    console.log('haha');
                    setTimeout(function () {
                      //要延时执行的代码
                      wx.switchTab({
                        url: '../hetong/hetong'
                      })
                    }, 1000) //延迟时间
                  }
                })
        }else{
          that.setData({
            yc_s:"display:none"
          })
          wx.showToast({
            title: '撤回失败！',
            icon: 'none',
            duration: 2000
          })
        }
        
      }
    })
   
  },
  ht_cz3:function(e){
    var ht_id = e.currentTarget.dataset.id; 
   wx.navigateTo({
     url: '../qianshu1/qianshu1?ht_id='+ht_id,
   })
  },
  // gr_xx:function(e){
  //   var gr_id = e.currentTarget.dataset.id; 
  //   wx.navigateTo({
  //     url: '../gr_xx1/gr_xx1?gr_id='+gr_id,
  //   })
  // },
  ht_cz2:function(e){
    var ht_id = e.currentTarget.dataset.id; 
    console.log(ht_id)
    wx.navigateTo({
      url: '../hetong_xq/hetong_xq?ht_id='+ht_id,
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    // var he_id = options.he_id;
    // var type = options.type;
      that.setData({
        type:app.globalData.type11
      })
    wx.request({
      url: app.globalData.url_l + 'api/member/hetong_xiang',
      method: 'post',
      data:{
          uid:app.globalData.uid,
         id:app.globalData.qs_ht
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        that.setData({
          faqi_ht:res.data.hetong,
          qshu_f:res.data.ht_user
        })
        
      }
    })
  },
  tongguo:function(e){
    var that = this;
    wx.request({
      url: app.globalData.url_l + 'api/order/contract_examine',
      method: 'post',
      data:{
          uid:app.globalData.uid,
          ht_id:app.globalData.qs_ht,
          status:"success"
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        console.log(res)
        if(res.data.code==0){
          wx.showToast({
            title: res.data.msg,
            icon: 'none',
            duration: 2000
          })
        }else if(res.data.code==1){
          wx.showToast({
            title: res.data.msg,
            icon: 'none',
            duration: 2000
          })
          that.onLoad();
        }
        
      }
    })
  },
  liyou:function(e){
    app.globalData.liyou = e.detail.value
  },
  guanbi:function(e){
    var that = this;
    that.setData({
      yc_s1:"display:none"
    })
  },
  zhidao1:function(e){
    var that = this;
    if(app.globalData.liyou==''||app.globalData.liyou==null||app.globalData.liyou==undefined){
              wx.showToast({
                title: "请输入驳回理由！",
                icon: 'none',
                duration: 2000
              })
    }else{
      wx.request({
            url: app.globalData.url_l + 'api/order/contract_examine',
            method: 'post',
            data:{
                uid:app.globalData.uid,
                ht_id:app.globalData.qs_ht,
                bo_con:app.globalData.liyou,
                status:"error"
            },
            header: {
              'content-type': 'application/x-www-form-urlencoded'
            },
            success: function (res) {
              console.log(res)
              if(res.data.code==0){
                wx.showToast({
                  title: res.data.msg,
                  icon: 'none',
                  duration: 2000
                })
              }else if(res.data.code==1){
                that.setData({
                  yc_s1:"display:none"
                })
                wx.showToast({
                  title: res.data.msg,
                  icon: 'none',
                  duration: 2000
                })
                that.onLoad();
              }
              
            }
          })
    }
  },
  bohui:function(e){
    var that = this;
    that.setData({
      yc_s1:"display:block"
    })
    
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})